<{extends file="../layout/layout.phtml"}>
<{block name='content'}>
<link rel="stylesheet" href="/css/admin_ad.css">
<div id='admin-ad-type-add'>
	<div>
		<form method="post" onsubmit='return false;' id='add_ad_type'>
			Type Name:<input type='text' name='name'>	
			<input type='hidden' name='status' value='1'>
			<input type='submit' name='submit' value='Save' class='ad_type_submit'>
			<span id="error_show"></span>
		</form>
	</div>
</div>

<script type="text/javascript">
	
	window.addEvent('domready',function(){
		var msg_div = $("error_show");
		var add_type_request = new Request.JSON({
			url:'/index.php/admin/ad/ajax_typeadd',
			method:'post',
			onRequest:function(){
 				msg_div.set('text', 'Loading...');
			},
			onSuccess: function(responseJson){
				alert(responseJson.msg)
	            msg_div.set('html', responseJson.msg);
	            if(responseJson.flag){
	                location.href='/index.php/admin/ad/typeindex';
	            }
	        },
	        onFailure: function(){
	            msg_div.set('text', 'Sorry, your request failed :(');
	        }
		});

		// and to send it:
	    $$(".ad_type_submit").addEvent('click',function(){
	        add_type_request.send($("add_ad_type").toQueryString()); 
	    })
	})
</script>
<{/block}>